import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class HeaderInfoServlet extends HttpServlet {
	protected void doGet(HttpServletRequest req, HttpServletResponse res) 
			throws ServletException, IOException {
		res.setContentType("text/html;charset=utf-8");
		PrintWriter out = res.getWriter();
		
		out.println("<HTML><HEAD><TITLE>Response 정보 출력 Servlet</TITLE>");
		out.println("</HEAD><BODY><H3>요청 헤더 정보</H3>");
		out.println("<pre>");
		
		Enumeration em = req.getHeaderNames();
		
		while (em.hasMoreElements()) {
			String s = (String)em.nextElement();
			out.println(s + " : " + req.getHeader(s));
		}
		
		out.println("</pre>");
		out.println("</BODY></HTML>");
		out.close();
	}
}
